﻿using System;

namespace GreenXi.Help.Curve
{
    public class IsNanHelp
    {
        public static double IsNanInfinity(double sum)
        {
            double rate = 0;
            try
            {
                if (double.IsNaN(sum))
                {
                    rate = 0;
                }
                else if (double.IsInfinity(sum))
                {
                    rate = 0;
                }
                else
                {
                    rate = Convert.ToInt32(sum);
                }
            }
            catch (Exception ex)
            {
                Helpers.Logger.Instance.Warning($"Catch IsNanInfinity {ex.Message}");
                throw new Exception(ex.Message);
            }
            return rate;
        }
    }
}
